package ssh;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class IpAddress {
	
		String ip;
		String port;
		
		
		public IpAddress(String ip){
				this.setIp(ip);
		}
		public String getIp() {
			return ip;
		}
		public void setIp(String ip) {
			if(validateIP(ip)){
				this.ip = ip;}
			else System.out.println("Formato de IP invalido!");
			
		}

		public boolean validateIP (String parameter){
			//Pattern regex = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
			Pattern regex = Pattern.compile("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)");
			Matcher match = regex.matcher(parameter);
			return match.find();
		}	
		
		
		
			
			
			
			
		
}
